/***********************************************************************************
  * File:			key.h
  * Version:		V1.0
  * Date:			2021.5.26
  * Description:	key应用函数接口
***********************************************************************************/
#ifndef __KEY_H__
#define	__KEY_H__

/* 头文件 */
#include "board.h"
#include "n32g45x.h"
#include "n32g45x_gpio.h"
#include "n32g45x_exti.h"

/* 宏定义 */
#define KEY1_INPUT_PORT				GPIOA
#define KEY1_INPUT_PIN				GPIO_PIN_4
#define KEY1_INPUT_EXTI_LINE		EXTI_LINE4
#define KEY1_INPUT_PORT_SOURCE		GPIOA_PORT_SOURCE
#define KEY1_INPUT_PIN_SOURCE		GPIO_PIN_SOURCE4
#define KEY1_INPUT_IRQn				EXTI4_IRQn
#define KEY1_INPUT_IRQHandler		EXTI4_IRQHandler

#define KEY2_INPUT_PORT				GPIOA
#define KEY2_INPUT_PIN				GPIO_PIN_5
#define KEY2_INPUT_EXTI_LINE		EXTI_LINE5
#define KEY2_INPUT_PORT_SOURCE		GPIOA_PORT_SOURCE
#define KEY2_INPUT_PIN_SOURCE		GPIO_PIN_SOURCE5
#define KEY2_INPUT_IRQn				EXTI1_IRQn
#define KEY2_INPUT_IRQHandler		EXTI1_IRQHandler

#define KEY3_INPUT_PORT				GPIOA
#define KEY3_INPUT_PIN				GPIO_PIN_6
#define KEY3_INPUT_EXTI_LINE		EXTI_LINE6
#define KEY3_INPUT_PORT_SOURCE		GPIOA_PORT_SOURCE
#define KEY3_INPUT_PIN_SOURCE		GPIO_PIN_SOURCE6
#define KEY3_INPUT_IRQn				EXTI2_IRQn
#define KEY3_INPUT_IRQHandler		EXTI2_IRQHandler

#define KEY_ON	0
#define KEY_OFF	1

/* 函数声明 */
void KeyInputExtiInit(GPIO_Module* GPIOx, uint16_t Pin, uint16_t key_id);
uint8_t Key_Scan(GPIO_Module* GPIOx, uint16_t Pin);
void Key_GPIO_Config(GPIO_Module* GPIOx, uint16_t Pin);

#endif /* __KEY_H__ */

